package org.wk.account.api.controller;

import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.wk.account.service.*;
import org.wk.core.common.view.ResponseVo;

/**
 * @ClassName ExchangeCNYController
 * @Description 提现服务
 * @Author ZhaoPing'an
 * @Date 2018/6/29 11:42
 */
@RestController
public class ExchangeCNYController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private SubAccountLingService lingService;
    @Autowired
    private SubAccountZuanService zuanService;

    /**
     * @Description 鲸灵提现服务
     * @param jsonObject
     * @author ZhaoPing'an
     * @Date 2018/6/27 15:27
     */
    @RequestMapping(value="/accounts/jing_ling/exchangecny",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String lingExchangecny(@RequestBody JSONObject jsonObject){
        ResponseVo result = new ResponseVo();
        logger.info("鲸灵提取现金=====>>>{}",jsonObject.toString());
        result = lingService.lingExchangeCNY(jsonObject);
        logger.info("鲸灵提取现金结果=====>>>{}", result.toString());
        return result.toString();
    }

    /**
     * @deprecated 查看当前用户是否有未完成的提现申请
     * @param
     * @author ZhaoPing'an
     * @date 2018/7/7 15:25
     */
    /*@RequestMapping(value="/accounts/jing_ling/exchangecnyStatus",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String exchangecnyStatus(){
        ResponseVo result = new ResponseVo();
        logger.info("获取当前用户鲸灵提现状态=====>>>{}");
        result = lingService.exchangecnyStatus();
        logger.info("当前用户鲸灵提现状态结果=====>>>{}", result.toString());
        return result.toString();
    }*/

    /**
     * @Description 鲸钻提现服务
     * @param jsonObject
     * @author ZhaoPing'an
     * @Date 2018/6/28 11:52
     */
    @RequestMapping(value="/accounts/jing_zuan/exchangecny",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String zuanExchangecny(@RequestBody JSONObject jsonObject){
        ResponseVo result = new ResponseVo();
        logger.info("鲸钻提取现金=====>>>{}",jsonObject.toString());
        result = zuanService.zuanExchangeCNY(jsonObject);
        logger.info("鲸钻提取现金结果=====>>>{}", result.toString());
        return result.toString();
    }
}
